CXX=g++
CXXFLAGS=-Wall -pedantic $(FLIB)
## all BenchMarks
BM=test1 test2 test3 test4 test5 test6 test7 test8
## benchmarks of sympycpp
BMScppName=$(BM:%=%.sympycpp)
BMGinacName=$(BM:%=%.ginac)
BMMathematica=$(BM:%=bench.%.mathematica.bench)
BMname=$(BMScppName) $(BMGinacName)

BMrun=$(BMname:%=bench.%.bench) $(BMMathematica) 
## compile all benchmarks
all: $(BMname) 
	@echo " "
run: sage1 sympy1 $(BMrun)
	@echo " "
## static compilation of all benchnarks
static-all:
	make all FLIB="-static"
## dynamic compilation of all benchnarks
shared-all:
	make all FLIB="-fPIC"
clean:
	rm -f *.o *ginac.bench *sympycpp.bench *.core *.out
## default rule for all benchmarks
%sympycpp:
	$(CXX) $(CXXFLAGS) $@.cpp -o $@.bench -lsympycpp -lgmpxx -lgmp 
%ginac:
	$(CXX) $(CXXFLAGS) $@.cpp -o $@.bench -L /usr/local/lib/ -I /usr/local/include/ -lcln -lginac
bench%bench:
	/usr/bin/time -f "$(@:bench.%.bench=%): %e" -o times --append ./$(@:bench.%=%)
sage1:
	/usr/bin/time -f "test1.sage: %e" -o times --append sage ./test1.sage.bench 
sage2:
	@/usr/bin/time -f "$@: %e" sage ./test2.sage.bench
sage3:
	@/usr/bin/time -f "$@: %e" sage ./test3.sage.bench
sage4:
	@/usr/bin/time -f "$@: %e" sage ./test4.sage.bench
sage5:
	@/usr/bin/time -f "$@: %e" sage ./test5.sage.bench
sage6:
	@/usr/bin/time -f "$@: %e" sage ./test6.sage.bench
sage7:
	@/usr/bin/time -f "$@: %e" sage ./test7.sage.bench
sage8:
	@/usr/bin/time -f "$@: %e" sage ./test8.sage.bench

sympy1:
	/usr/bin/time -f "test1.sympy: %e" -o times --append python ./test1.sympy.bench 
sympy2:
	@/usr/bin/time -f "$@: %e" python ./test2.sympy.bench
sympy3:
	@/usr/bin/time -f "$@: %e" python ./test3.sympy.bench
sympy4:
	@/usr/bin/time -f "$@: %e" python ./test4.sympy.bench
sympy5:
	@/usr/bin/time -f "$@: %e" python ./test5.sympy.bench
sympy6:
	@/usr/bin/time -f "$@: %e" python ./test6.sympy.bench
sympy7:
	@/usr/bin/time -f "$@: %e" python ./test7.sympy.bench
sympy8:
	@/usr/bin/time -f "$@: %e" python ./test8.sympy.bench
